/**
 * 部署环境枚举
 */
export enum DeployEnvironment {
  DEVELOPMENT = 'development', // 开发环境
  TESTING = 'testing',         // 测试环境
  PRODUCTION = 'production'    // 生产环境
}

/**
 * 部署状态枚举
 */
export enum DeployStatus {
  PENDING = 'pending',     // 待部署
  PROCESSING = 'processing', // 部署中
  IN_PROGRESS = 'in_progress', // 部署中（与API文档一致）
  SUCCESS = 'success',     // 部署成功
  FAILED = 'failed'        // 部署失败
}

/**
 * 部署步骤枚举
 */
export enum DeployStep {
  UPLOAD = 'upload',           // 上传包
  EXTRACT = 'extract',         // 解压包
  COPY_CONFIG = 'copy_config', // 拷贝配置
  NPM_INSTALL = 'npm_install', // NPM安装（前端项目）
  NPM_BUILD = 'npm_build',     // NPM构建（前端项目）
  RESTART = 'restart',         // 重启服务（后端项目）
  COMPLETE = 'complete'        // 完成
}

/**
 * 部署步骤状态
 */
export interface DeployStepStatus {
  step: DeployStep
  status: DeployStatus
  message?: string
  startTime?: string | null
  endTime?: string | null
}

/**
 * 部署记录
 */
export interface DeployRecord {
  id: string
  projectId: string
  projectName: string
  environment: DeployEnvironment
  status: DeployStatus
  version: string
  steps: DeployStepStatus[]
  log?: string
  createTime: string
  updateTime: string
}

/**
 * 部署详情（根据API文档）
 */
export interface DeployDetail {
  id: number
  project_version_id: number
  environment: string
  status: DeployStatus
  deploy_path: string
  logs: string | null
  started_at: string
  completed_at: string | null
  deployed_by: string
}

/**
 * 部署创建请求
 */
export interface DeployCreateRequest {
  projectId: string | number
  environment: DeployEnvironment
  version?: string
  project_version_id?: number
  deploy_path?: string
  deployed_by?: string
}

/**
 * 部署日志查询请求
 */
export interface DeployLogRequest {
  deployId: string
  from?: number
}

/**
 * 部署目录
 */
export interface DeployDirectory {
  id: string
  name: string
  path: string
}

/**
 * 目录列表响应
 */
export interface DirectoriesResponse {
  directories: DeployDirectory[]
}

/**
 * 文件信息
 */
export interface FileInfo {
  file_name: string
  file_path: string
  size_bytes: number
  size_human: string
  modified_time: string
  version: string
  build_date: string
}

/**
 * 扫描目录响应
 */
export interface ScanResponse {
  directory: DeployDirectory
  files: FileInfo[]
}

/**
 * 本地部署请求
 */
export interface LocalDeployRequest {
  directory_id: string
  file_name: string
  environment: DeployEnvironment
  deployed_by?: string
  version?: string // 添加版本号字段
}

/**
 * 本地部署响应
 */
export interface LocalDeployResponse {
  message: string
  file_path: string
  environment: string
  deployed_by: string
}
